from info.lib.yuntongxun.CCPRestSDK import REST


accountSid = '8a216da8679d0e9d0167c165d2d71'

accountToken = '7396fa20c9a64a1292cfb92b434d427f'

appId = '8a216da8679d0e9d0167c165d329159f'

serverIP = 'app.cloopen.com'


serverPort = '8883'

softVersion = '2013-12-26'


class CCP(object):

    def __new__(cls,*args,**kwargs):
        if not hasattr(CCP,"instance"):
            cls.instance = super(CCP,cls).__new__(cls,*args,**kwargs)
            cls.instance.rest = REST(serverIP,serverPort,softVersion)
            cls.instance.rest.setAccount(accountSid,accountToken)
            cls.instance.rest.setAppId(appId)
        return cls.instance

    def send_template_sms(self,to,datas,temp_id):

        result = self.rest.sendTemplateSMS(to,datas,temp_id)

        if result.get("statusCode") == "000000":

            return 0
        else:
            return -1

if __name__ == '__main__':
    ccp = CCP()
    result = ccp.send_template_sms('18953020056',['1234',5],1)
    print(result)